﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Demo.Framework.OOP
{
    
    
    class Program
    {
        static void Main(string[] args)
        {

            // test try-catch
            TestMethod();
            try
            {
                TestMethod();
            }
            catch (Exception)
            {
                
            }
            finally
            {
                
            }
            
            // Shadow / Hiding vs overriding
            Shadow s = new Shadow();
            s.Method1();
            s.Method2();
            s.Method3();

            ((Base)s).Method1(); // child method
            ((Base)s).Method2(); // base method
            ((Base)s).Method3(); // base method

            var staticContr = new StaticConstructor();

                        
            Console.Read();
        }

        static void TestMethod()
        {
            try
            {
                throw new Exception("Test Exception");
            }
            catch (Exception)
            {
                //throw new Exception("Inner Exception");
            }
            //finally
            //{
            //    throw new Exception("Finally Exception");
            //}
        }
    }

    public class Base
    {
        public String SampleProperty { get; private set; }
        public virtual void Method1()
        {
            Console.WriteLine("This is Base Method1");
        }

        public void Method2()
        {
            Console.WriteLine("This is base Method2");
        }

        public virtual void Method3()
        {
            Console.WriteLine("This is Base Method3");
        }
    }

    public class Shadow :Base
    {
        public override void Method1()
        {            
            Console.WriteLine("Override - This is Shadow Method1");
        }

        public new void Method2()
        {
            Console.WriteLine("Shadow - This is Shadow Method2");
        }

        public new void Method3()
        {
            Console.WriteLine("Shadow - This is Shadow Method3");
        }
    }

        
    /* Structure
     * Value Type - Stored on Heap, Pass as Value
     * Can implement Interfaces
     * 
     */

    public struct BaseStruct
    {
    }

    public struct MyStructure:IDisposable
    {
        // structures cannot have default constructors
        //public MyStructure()
        //{
        //}
        public void Dispose()
        {
            throw new NotImplementedException();
        }        
    }

    public interface ITestInterface
    {
        string MyProperty { get; set; }
        void TestMethod();
    }

    public class TestClass : ITestInterface
    {
        public virtual string MyProperty
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void TestMethod()
        {
            throw new NotImplementedException();
        }
    }
}
